import pytest
from selenium.webdriver import Chrome
from commons.funcs import user_login
from commons.pages import UserLoginPage
import logging

logger = logging.getLogger(__name__)

@pytest.fixture(scope="session")
def driver():
    """启动浏览器"""
    d = Chrome()
    d.maximize_window()  # 最大化屏幕
    d.implicitly_wait(10)  # 隐式等待，用于解决由于”元素不存在“产生的报错
    yield d
    d.quit()


@pytest.fixture(scope="session")
def user_driver(driver):
    """登录账号"""
    page = UserLoginPage(driver)
    msg = page.login("zhaoqiqi", "zhaoqiqi")
    # msg = user_login(driver, "zhaoqiqi", "zhaoqiqi")
    assert msg == "登录成功"
    yield driver


@pytest.fixture(scope="session")
def new_order(driver):
    """创建订单"""
